package com.frank.towerrush.split;

import android.graphics.RectF;

/**
 * 用来定位位置
 * 
 * @author Frank
 *
 */
public class Location {
    /**
     * 当前位置
     */
    private Flag loc;

    private int height;
    private int width;

    private RectF rectf;

    public Location(Flag loc) {
        this.setLoc(loc);
    }

    /**
     * @return loc
     */
    public Flag getLoc() {
        return loc;
    }

    /**
     * @param loc
     *            要设置的 loc
     */
    public void setLoc(Flag loc) {
        this.loc = Flag.newFlag(loc);
        setRectf();
    }

    /**
     * 设置图片尺寸
     * 
     * @param height
     *            高
     * @param width
     *            宽
     */
    public void setSize(int height, int width) {
        this.height = height;
        this.width = width;
        setRectf();
    }

    /**
     * 设置范围
     */
    private void setRectf() {
        rectf = new RectF(loc.getX() - width / 2, loc.getY() - height / 2, loc.getX() + width / 2,
                loc.getY() + height / 2);
    }

    /**
     * @return rectF
     */
    public RectF getRectF() {
        return rectf;
    }

}
